
#include <sys/stat.h>   
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h> 
#include "bit_io.h"

bool BZA_BitIo::set_options( char* _filename, BZA_BitIo_Mode _mode, BZA_SIZE _initial_pos_in_file )
{
	int oflag;
	__off_t as;
			
	
	mode = _mode;
	if ( fd != -1 )
	{
		close();
	}
	
	switch( mode )
	{
		case BZA_BITIO_MODE_WRITE:	oflag = O_WRONLY; break;
		case BZA_BITIO_MODE_READ:	oflag = O_RDONLY; break;
		case BZA_BITIO_MODE_NONE:	return TRUE;
		default:
			abort();
	} 
	fd = open64( _filename, O_CREAT | oflag );
	
	lseek64( fd, _initial_pos_in_file, SEEK_SET );
}